package cn.edu.lzu.unitweb.controller;

import cn.edu.lzu.common.assist.ResponseResult;
import cn.edu.lzu.entity.Examiner;
import cn.edu.lzu.entity.FillMedItem;
import cn.edu.lzu.service.FillMedItemService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.PrincipalCollection;
import org.apache.shiro.subject.support.DefaultSubjectContext;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * @PackageName: cn.edu.lzu.unitweb.controller
 * @ClassName: FillMedItemController
 * @Description: TODO
 * @Author: 张琦[QQ:3098086691]
 * @Date: 2020/4/10 18:00
 * @Version: 1.0
 */
@Controller
public class FillMedItemController {
    @Resource
    private FillMedItemService fillMedItemService;

    @ResponseBody
    @RequestMapping("/submitMedClauseValue")
    public ResponseResult submitMedClauseValue(FillMedItem fillMedItem){
        System.out.println("fillMedItem = " + fillMedItem);
        Session session= SecurityUtils.getSubject().getSession();
        Examiner examiner=(Examiner)((PrincipalCollection)session.getAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY)).getPrimaryPrincipal();
        fillMedItem.setExaminerId(examiner.getExaminerId());
        ResponseResult responseResult=fillMedItemService.fillMedItemValue(fillMedItem);
        return responseResult;
    }
}
